package java07;
import java.io.*;
public class FileWriterTest01 {
    public static void main(String[] args){
        FileWriter fileWriter = null;
        try {
            //创建字符输出流对象，并指定输出文件
            fileWriter = new FileWriter("D:\\JAVA\\source\\writer.txt");
            //fileWriter = new FileWriter("D:\\JAVA\\source\\writer.txt",true);//可在源文件上追加内容
            //将定义的字符写入文件
            fileWriter.write("轻轻的我走了，\r\n");
            fileWriter.write("正如我轻轻的来，\r\n");
            fileWriter.write("我轻轻的招手，\r\n");
            fileWriter.write("作别西天的云彩。\r\n");
        } catch (IOException e) {
            e.printStackTrace();
        }finally {
            //关闭流
            if(fileWriter != null){
                try {
                    fileWriter.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }
    }
}
